package org.spring.springboot.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component  //被 spring 容器管理
@Order(10)  //如果多个自定义的 CommandLineRunner，用来标明执行的顺序，数字越小，顺序越靠前
public class CommandLineRunnerStartService  implements CommandLineRunner{

	private static Logger logger =  LoggerFactory.getLogger(CommandLineRunnerStartService.class);
	
	@Autowired
	private UserService userService;
	
	@Override
	public void run(String... args) throws Exception {
		logger.info("===SpringBoot项目启动后，执行CommandLineRunnerStartService方法，进行初始化操作 =============");
		//执行自己的业务逻辑
		System.out.println(userService.Sel(1).toString());
	}

}
